<script setup>
import Sidebar from './components/Sidebar.vue'
import { RouterView, useRouter } from 'vue-router'
import { ElMessage } from 'element-plus'

const router = useRouter()
const handleLogout = () => {
  localStorage.removeItem('token')
  ElMessage.success('已退出登录')
  router.push('/login')
}
</script>

<template>
  <div class="layout-container">
    <Sidebar class="sidebar" />
    <div class="main-content">
      <div class="logout-bar">
        <el-button type="danger" size="small" @click="handleLogout">退出登录</el-button>
      </div>
      <RouterView />
    </div>
  </div>
</template>

<style scoped>
.layout-container {
  display: flex;
  height: 100vh;
}

.sidebar {
  width: 200px;
  background-color: #E8C316;
  color: white;
  position: absolute;
  left: 0;

}

.main-content {
  flex: 1;
  padding: 20px;
  background-color: #f0f2f5;
  position: absolute;
  left: 200px;
  height: 100%;
  width: calc(100% - 200px);
  box-sizing: border-box;
}
.logout-bar {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  margin-bottom: 16px;
}
</style>